<!--公共头部-->
{template 'aitimt/common/header'}
	<style>
		.mui-input-row{overflow: unset;}
		.mui-search input[type=search] {background-color: #EFEFEF;width: 80%;border-radius: 3.125rem;border: 1px #eee solid;height: 2.5625rem;}
		.top-slider{z-index: 15;margin-top:15% ;overflow: unset;}
		.top-slider .mui-slider-group .mui-slider-item img{width: 100%;}
		.mui-indicator .mui-active{background-color:#000000;}
		.mui-search .mui-placeholder{color: #595757;line-height: 2.5rem;font-size: 0.9375rem;width: 45%;}
		.mui-segmented-control.mui-segmented-control-inverted .mui-control-item.mui-active{color: #585858;border-bottom: 0;}
		.mui-bar-tab .mui-tab-item.mui-active{color: #ea4609;}
		.mui-bar-nav~.mui-content{margin-bottom: 10%;margin-top: 5%;}
		.mui-table-view .mui-media-object{max-width: 40%;}
		.mui-content{background-color: #FFFFFF;}
		.mui-slider{background-color: #efefef;}
		.mui-slider-indicator.mui-segmented-control .mui-control-item {padding: 1px;border-left:1px solid #c1c1c1 ;color: #585858;}
		.mui-slider .mui-segmented-control.mui-segmented-control-inverted .mui-control-item.mui-active{border-bottom:3px solid #e94709 ;color: #585858;}
		.mui-card{color: #595757;font-size: 15px;margin: 0;margin-top: 10%;box-shadow:none;}
		.my-data{float: right;margin-right: 10%;}
		.mui-table-view-chevron{background-color: #EEEEEE;}
		.mui-collapse{background-color: #FFFFFF;}
		.mui-table-view-cell.mui-active, .mui-table-view-cell>a:not(.mui-btn).mui-active{background-color: #FFFFFF;}
		.mui-icon-forward{position: absolute;top: 35%;right: 5%;}
		#offCanvasSideScroll{background-color: #ffffff;margin-top: 15%;}
		.mui-off-canvas-wrap .mui-inner-wrap{background-color: #EEEEEE;}
		.mess{width: 100%;background: #ffffff;padding: 2% 5%;margin: 0;border-bottom: 1px solid #eeeeee;}
		.mui-input-row label{width: 25%;padding: 11px 0 11px 15px}
		.mui-input-row label~input, .mui-input-row label~select, .mui-input-row label~textarea{width: 75%}
		.mui-bar .mui-btn-block{border: 0;background: #e94709}
		.mui-table-view-cell.avatar{line-height:40px;}
		.mui-table-view-cell.avatar .upload-btn{position: absolute;top: 0;height: 100%;width: 100%;left: 0;}
		.mui-table-view-cell.avatar .upload-btn div{ width:100%!important; height:100%!important;}
		.mui-table-view-cell.avatar .head-img{border-radius: 75%;width: 50px;vertical-align: middle;}
		.webuploader-element-invisible{position: unset!important;opacity: 0;height: 100%;}
		.cropper-bg{height: 80%!important;}
		.mui-table-view-chevron .mui-table-view-cell{padding-right: 58px;}

	</style>
	<header class="mui-bar mui-bar-nav">
		<a class="top-return" onclick="myreturn()"><img src="{$aideUrl}app/resource/aitimt/images/return.png" ></a>
		<a class="top-logo"><img src="{$aideUrl}app/resource/aitimt/images/logo.png" ></a>
		<!--公共菜单start -->
		{template 'aitimt/common/menu'}
		<!-- 公共菜单end-->
	</header>
<!--侧滑菜单容器-->
<div id="offCanvasWrapper" class="mui-off-canvas-wrap mui-draggable">
	<!--菜单部分-->
	<div class="mui-inner-wrap">
		<div class="mui-card">
		<ul class="mui-table-view mui-table-view-chevron">
			<li class="mui-table-view-cell avatar" style="margin-bottom: 20px;background: white;">
				<a class="mui-navigate-right">头像
					<span class="mui-pull-right">
						<img class="head-img mui-action-preview" width="80" src="{if !empty($people['avatar'])}{php echo tomedia($people['avatar'])}{else}{$aideUrl}app/resource/aitimt/images/my2.png{/if}">
					</span>
				</a>
				<div class="upload-btn js-avatar-avatar" style="position:absolute;"></div>
			</li>
			<script>
                util.img($('.js-avatar-avatar'), function(url){
                    $('.avatar img').attr('src', url.url);
                    $.post("{php echo app_url('home/index/mydata');}", {type : 'avatar',avatar: url.attachment, uid:{$people['uid']} }, function(data) {
                        data = $.parseJSON(data);
                        console.log(url.attachment);
                        if (data.type == 'success') {
                            $('.mui-media-object img').attr('src', url.url);
                            util.toast(data.message);
                        } else {
                            util.toast('更新失败');
                        }
                    })
                }, {
                    crop : true,
                    pxSize : 320,
                    aspectRatio:1/1
                });
			</script>
			<p class="mess js-change" data-type="remarks">昵称<span class="my-data">{$people['nickname']}</span></p>
			<p class="mess js-change" data-type="realname">姓名<span class="my-data">{$people['realname']}</span></p>
			<p class="mess js-change" data-type="gender">性别<span class="my-data">{if $people['gender']==1}男{elseif $people['gender']==2}女{else}保密{/if}</span></p>
			<p class="mess js-change" data-type="residecity">城市<span class="my-data">{if $people['residecity']}{$people['residecity']}{else}保密{/if}</span></p>
			<p class="mess js-change" data-type="mobile">手机<span class="my-data">{if $people['mobile']}{$people['mobile']}{else}保密{/if}</span></p>
			<p class="mess js-change" data-type="email">邮箱<span class="my-data">{if $people['email']}{$people['email']}{else}保密{/if}</span></p>
		</ul>
	</div>
	</div>
</div>
		<!-- 公共底部start -->
		{template 'aitimt/common/nav'}
		<!-- 公共底部end -->
<script>
    $(".js-change").on('tap',function(e) {
        e.detail.gesture.preventDefault(); //修复iOS 8.x平台存在的bug，使用plus.nativeUI.prompt会造成输入法闪一下又没了
        var $this = $(this);
        var uid={$people['uid']};
        var placeholder = '', params = '', value = '', type = $(this).data("type");
        switch(type){
            case 'remarks':placeholder = '请输入新的昵称';break;
            case 'realname':placeholder = '请输入真实姓名';break;
            case 'residecity':placeholder = '请输入城市名称';break;
            case 'mobile'      :placeholder = '请输入您的手机';break;
            case 'email':placeholder = '请输入您的邮箱';break;
            default:break;
        }
        if (type!='gender'){
            mui.prompt('资料修改', placeholder,' ', function(e) {
                if (e.index == 1) {
                    value = e.value;
                    if ($.trim(value)==''){
                        util.toast('更改信息不能为空');
                        return false;
                    }
                    if (type=='mobile'){
                        var pattern = /^1[0-9]{10}$/;

                        if (!pattern.test(value)) {
                            util.toast('手机号不合法');
                            return false;
                        }
					}
					if (type=='email'){
                        var emailreg = /^([\.a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;
                        if (emailreg.test(value))
                        {
                        }else {
                            util.toast('请输入正确的邮箱');
                            return false;
                        }
					}
                    switch(type){
                        case 'remarks':params = {remarks: value, type : type,uid:uid};break;
                        case 'realname':params = {realname: value, type : type,uid:uid};break;
                        case 'residecity':params = {residecity: value, type : type,uid:uid};break;
                        case 'mobile':params = {mobile: value, type : type,uid:uid};break;
						case 'email':params = {email: value, type : type,uid:uid};break;
                        default:break;
                    }
                    $.post("{php echo app_url('home/index/mydata');}", params, function(data) {
                        data = $.parseJSON(data);
                        if (data.type == 'success') {
                            util.toast(data.message);
                            $this.find('span').removeClass('mui-text-primary').text(value);
                        } else {
                            util.toast(data.message);
                        }
                    })
                }
            });
        }else{
            var options = {data: [{"text":"\u7537","value":1},{"text":"\u5973","value":2}]};
            var $this = $(this);
            util.poppicker(options, function(items){
                $.post("{php echo app_url('home/index/mydata');}", {'gender' : items[0].value, type : type,'uid':{$people['uid']}}, function(data) {
                    data = $.parseJSON(data);
                    if (data.type == 'success') {
                        util.toast(data.message);
                        $this.find('span').removeClass('mui-text-primary').text(items[0].value==1?'男':(items[0].value==2?'女':'保密'));
                    } else {
                        util.toast(data.message);
                    }
                })
            });
        }
    });
</script>
<script type="text/javascript">
    function myreturn() {
        location.href = "{php echo app_url('home/index/my')}";
    }

</script>


</body>

</html>
